import axios from "axios"

//   评论

//   评论2音乐
async function addComment(comment){
  var result
  await axios({
      baseURL: 'api/blogcomment/add',
      data: comment,
      headers: {'Content-Type': 'application/json;charset=UTF-8' },
      method: 'post',
  }).then(res => {
      result=res.data
      console.log(result);
  })
  return result
}

//    查看我的评论
async function myComment(){
  var result
  await axios({
      baseURL: 'api/blogcomment/myComment',
      method: 'get',
  }).then(res => {
      result=res.data
      console.log(result);
  })
  return result
}

// 删除评论
async function deleteComment(commentId){
  var result
  await axios({
      baseURL: 'api/blogcomment/delete/'+commentId,
      method: 'delete',
  }).then(res => {
      result=res.data
      console.log(result);
  })
  return result
}



//   是否点赞
async function orNotLike(commentId){
  var result
  await axios({
      baseURL: 'api/blogcomment/or/not/like/'+commentId,
      method: 'get',
  }).then(res => {
      result=res.data
      console.log(result);
  })
  return result
}


// 点赞
async function likeComment(commentId){
  var result
  await axios({
      baseURL: 'api/blogcomment/like/'+commentId,
      method: 'put',
  }).then(res => {
      result=res.data
      console.log(result);
  })
  return result
}


// 根据blogId查询评论列表
async function getCommentByBlogId(blogId){
  var result
  await axios({
      baseURL: 'api/blogcomment/byblogid/'+blogId,
      method: 'get',
  }).then(res => {
      result=res.data
      console.log(result);
  })
  return result
}

// 根据blogId查询评论列表
async function getCommentByBlogId2Page(blogId,pageNumber,pageSize){
  var result
  await axios({
      baseURL: 'api/blogcomment/byblogid2page/'+blogId+"/"+pageNumber+"/"+pageSize,
      method: 'get',
  }).then(res => {
      result=res.data
      console.log(result);
  })
  return result
}






export default {
  name: 'BlogCommentAPI',
  addComment,
  myComment,
  deleteComment,
  orNotLike,
  likeComment,
  getCommentByBlogId,
  getCommentByBlogId2Page,
}
